package hotel.callback.oversea.service.impl;

import hotel.base.oversea.service.impl.BaseServiceImpl;
import hotel.base.oversea.utils.StringUtil;
import hotel.callback.oversea.entity.meituan.MtHotelDetail;
import hotel.callback.oversea.entity.meituan.MtHotelDetailOperLog;
import hotel.callback.oversea.mapper.MtHotelDetailMapper;
import hotel.callback.oversea.mapper.MtHotelDetailOperLogMapper;
import hotel.callback.oversea.service.MtHotelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Slf4j
@Service
public class MtHotelServiceImpl extends BaseServiceImpl implements MtHotelService {

    @Autowired
    MtHotelDetailOperLogMapper mtHotelDetailOperLogMapper;
    @Autowired
    MtHotelDetailMapper mtHotelDetailMapper;

    @Override
    public void updateStateTypeByHotelId(MtHotelDetail mtHotelDetail) {
        //更新酒店数据库信息
        /*mtHotelDetailMapper.updateStateTypeByHotelIds(map);
        Integer statusType = (Integer)map.get("statusType");
        String idsStr = (String)map.get("hotelIds");*/
        /*mtHotelDetail.setModifyTime(new Date());
        Example example = new Example(MtHotelOrderBooking.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("mtHotelId",mtHotelDetail.getMtHotelId());
        mtHotelDetailMapper.updateByExampleSelective(mtHotelDetail,example);*/

        MtHotelDetailOperLog mtHotelDetailOperLog = new MtHotelDetailOperLog();
        mtHotelDetailOperLog.setMtHotelId(mtHotelDetail.getMtHotelId());
        mtHotelDetailOperLog.setState(mtHotelDetail.getMtStatusType());
        mtHotelDetailOperLog.setType(3);//异步通知酒店
        mtHotelDetailOperLog.setRemark(mtHotelDetail.getRemark());
        updateStateHotelLog(mtHotelDetailOperLog);

    }
    public void updateStateHotelLog(MtHotelDetailOperLog mtHotelDetailOperLog) {
        mtHotelDetailOperLog.setCreateTime(new Date());
        mtHotelDetailOperLog.setId(StringUtil.getUUID());
        mtHotelDetailOperLogMapper.insert(mtHotelDetailOperLog);
    }


}
